<?php

class Cms_Controller_Plugin_CustomControllerAction extends Zend_Controller_Action {

    public $db;
    public $configuration;
    public $seo_config;

    public function init() {
     
        $this->db = Zend_Registry::get('db');
    
     //   $this->configuration = DatabaseObject_Config::GetConfig($this->db);
     //   $this->seo_config = DatabaseObject_SeoConfig::GetConfig($this->db);
    //    $menu = DatabaseObject_Pages::GetPages($this->db, array('where' => 'displayInMenu = 1'));
    //    $footer_text = $this->configuration['footer_text'];
   //     $this->view->menu = $menu;
   //     $this->view->footer_text = $footer_text;
    }
    
/*    public function getConfigValue($name) {
        return DatabaseObject_Config::GetConfigValue($this->db, $name);
    }
    */
    

    public function getUrl($action = null, $controller = null, $module = null) {
        $url = rtrim($this->getRequest()->getBaseUrl(), '/') . '/';
        $url .= $this->_helper->url->simple($action, $controller, $module);

        return '/' . ltrim($url, '/');
    }

    public function getCustomUrl($options, $route) {
        return $this->_helper->url->url($options, $route);
    }

    public function preDispatch() {
        /*$auth = Zend_Auth::getInstance();
        if ($auth->hasIdentity()) {
            $this->view->authenticated = true;
            $this->view->identity = $auth->getIdentity();
        }
        else
            $this->view->authenticated = false;*/
        
        //$this->db = Zend_Registry::get('db');
       // echo "!!<pre>"; print_r($this->db);echo "</pre>";
    }

    public function postDispatch() {
        $this->view->isXmlHttpRequest = $this->getRequest()->isXmlHttpRequest();
        
      //  $this->view->config = Zend_Registry::get('config');
    }

    public function sendJSON($data) {
        $this->_helper->viewRenderer->setNoRender();
        $this->getResponse()->setHeader('content-type', 'application/json');

        echo Zend_Json::encode($data);
    }
    
    public function writeLog($note) {
        DatabaseObject_Logger::WriteLog($this->db, $note);
    }
}

?>
